<?php
class Apps_Auth extends Zend_Auth {
	const ADMIN    = 'admin';
	const CUSTOMER = 'customer';
	const PROVIDER = 'provider';

	protected static $_namespace = 'Apps.Auth';
	protected static $_authAdmin;
	protected static $_authCustomer;
	protected static $_authProvider;

	protected function __contruct($sub) {
		$this->setStorage(new Zend_Auth_Storage_Session($this->_namespace, $sub));
	}

	/** Default to getInstanceCustomer */
	public static function getInstance() {
		return self::getInstanceCustomer();
	}

	public static function getInstanceAdmin() {
		if(!self::$_authAdmin) {
			$authAdmin = new self();
			$authAdmin->setStorage(
			                 new Zend_Auth_Storage_Session(
			                     self::$_namespace, self::ADMIN));

			self::$_authAdmin = $authAdmin;
		}

		return self::$_authAdmin;
	}
	public static function getInstanceCustomer() {
		if(!self::$_authCustomer) {
            $authCustomer = new self();
            $authCustomer->setStorage(
                             new Zend_Auth_Storage_Session(
                                 self::$_namespace, self::CUSTOMER));

            self::$_authCustomer = $authCustomer;
		}
        return self::$_authCustomer;
	}
    public static function getInstanceProvider() {
        if(!self::$_authProvider) {
            $authProvider = new self();
            $authProvider->setStorage(
                             new Zend_Auth_Storage_Session(
                                 self::$_namespace, self::PROVIDER));

            self::$_authProvider = $authProvider;
        }
        return self::$_authProvider;
    }
}